package com.qf.util;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * 构建Java与ES交互的客户端
 * @author zjw
 */
public class ESClientUtil {


    /**
     * 获取与ES交互的client对象
     * @return
     */
    public static RestHighLevelClient getClient(){

        HttpHost httpHost = new HttpHost("192.168.41.98",9200);

        RestClientBuilder restClientBuilder = RestClient.builder(httpHost);

        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(restClientBuilder);

        return restHighLevelClient;
    }

}
